package com.foxzzz.contest83;

public class Solution2 {
        public String maskPII(String S) {
            S=S.replace("+","").replace("(","").replace(")","")
                    .replace("-","");
           if('0'<=S.charAt(0)&&S.charAt(0)<='9')
           {
             if(S.length()==10)
                 return "***-***-"+S.substring(6,10);
             else
                 return "+***-***-"+S.substring(S.length()-4,S.length());
           }else {
             return (S.substring(0,1)+"*****"+ S.substring(S.indexOf("@")-1,S.length())).toLowerCase();
           }

        }
    //a-97 z-122 A-65 Z-90 0-48 9-57
    public static void main(String[] args) {
        System.out.println(new Solution2().maskPII("AB@qq.com"));
        System.out.println(new Solution2().maskPII("LeetCode@LeetCode.com"));
        System.out.println(new Solution2().maskPII("1(234)567-890"));
        System.out.println(new Solution2().maskPII("86-(10)12345678"));
        System.out.println(new Solution2().maskPII("+(501321)-50-23431"));
    }


}
